When mysql processes a unique index, it updates the index. If it does not exist, it should be very common to insert the index. There are many similar articles on the Internet, today I will talk about the problems and methods that may occur when this unique index is a unique index for multiple columns. Method 1: use? INSERTINTO? ON... DUPLICATEKEYUPDATE...: The ta
If mysql processes an index, it is updated. If there is no index, it is inserted (multiple columns of unique indexes). If there is no index, It is very common to insert the index, there are many similar articles on the Internet. Today I will talk about the problems and methods that may occur when the unique index is a unique index of
Tags: english sep chinese img Parallel src segmentation Math Group BYDatabase structure And I want to make the same person's different grades into this person. displayed on different columns of this line, this time divided into 2 shows: The first shows----"Multiple rows to one column" (the merged data is on the same column): SQL is as follows: The second shows----"Multiline
MySQL index usage instructions (single-column index and multi-column index), mysql multiple columns
1. Single Column Index
In the performance optimization process, selecting the columns to create an index is one of the most important steps. You can consider using two types o
Implementation of different values for mysql batch update and batch update of multiple records bitsCN.com
Batch update
The mysql update statement is simple. to
Mysql tables are sorted by multiple columns to obtain the first or next entry of a specified value. how can we make it simple? mysql, table name: tblsale, there are two fields, date and index, to determine a sales order (n orders in a day are identified by index). the records in the table are not necessarily discharged
Concatenate the values of multiple queried columns into a string bitsCN.com using SQL.
Concatenate the values of multiple queried columns into a string using SQL.
MySQL:
[SQL]
-- Concatenate a single column. first, locate a row, add a comma, and then splice the nex
Label:ref:http://blog.csdn.net/priestmoon/article/details/7677452Group_concat:group_concat(distinct name) group_concat(name separator ‘;‘) // 默认是,group_concat(name order by name desc)SELECT * from Shelvesopbusinessrel;SELECT s0.id,s0.listnum,s0.warehouseid,s0.businessquantity,s0.productquantity,s0.printdate,group_concat (Rel.businessnum)From Shelvesoplist S0Left Join Shelvesopbusinessrel relOn s0.id = Rel.shelvesoplistidGROUP by S0.listnumORDER by S0.id DESC;
'ENDWHERE ID in (All-in-a- Here, a MySQL statement has been completed to update multiple records.But to use in the business, you need to combine the service-side language, here in PHP, for example, constructs this MySQL statement: The code is as follows:$display _order = Array (1 = 4,2 = 1,3 = 2,4 = 3,5 = 9,6 = 5,7 =
the data is updated, and the WHERE clause ensures that only 3 rows of data are executed.
If you update multiple values, you need to modify them only slightly:
The code is as follows
UPDATE Categories
SET Display_order = case ID
When 1 THEN 3
When 2 THEN 4
When 3 THEN 5
End,
title = case ID
When 1 THEN ' New Title
? MySQL does not provide a straightforward way to implement batch updates, but it can be accomplished with a little bit of skill.
code as follows:
UPDATE mytable
SET myfield = case ID
When 1 Then ' value '
When 2 Then ' value '
When 3 Then ' value '
END
WHERE ID in (All-in-a-
This is a small trick to implement a batch update.
As an example:
cod
evaluation ', MAX (if (course= ' language ', familyevaluate,null)) As ' family evaluation ', MAX (if (course= ' language ', societyevaluate,null)) as ' social assessment ',
max (if (course= ' English ', score,0)) as ' English ', Max (if ( Course= ' English ', bossevaluate,null) as ' principal evaluation ', MAX (if (course= ' English ', familyevaluate,null)) as ' family Assessment ', Max (if (course= ' English ', Societyevaluate,null) as ' social assessment ' from
ds_wjytest2.student Group by na
Batch update
The mysql update statement is simple. to update a field of a piece of data, write as follows:
Copy codeThe Code is as follows:UPDATE mytable SET myfield = 'value' WHERE other_field = 'other _ value ';
If the same field is updated to the same value, mysql is also
Perform updates on a single table nothing more to say than to update table_name set col1 = Xx,col2 = yy where col = zz, which is mainly the setting of the Where condition. Sometimes updating a table may involve more than one datasheet, for example:
The code is as follows
Copy Code
Update Table_1 Set score = score + 5 where UID in (select UID from table_2 where sid = 10);In fact,
Mysql update modifies multiple data entries and mysql updatesGenerally, the following SQL statement is used to update the field value:Copy codeThe Code is as follows:UPDATE mytable SET myfield = 'value' WHERE other_field = 'other _ value ';However, what if you want to
And MySQL in contrast to see: http://blog.csdn.net/rainyspring4540/article/details/50231435
This is the oracle10g environment.
The database structure is as follows:
If I want to show the same name on the same line, there are 2 basic shows:
First presentation (displayed on different columns of the same row)
Its SQL is as follows:
Select Name,
max (decode (type, ' math ', score,0) as math,
max (de
Batch update names separated by commas (,) (multiple IDs separated by commas (,) in a department are converted into names separated by commas (,) (mysql) and comma (,) mysqlUpdate dept B, (select group_concat (t. deptId), group_concat (d. deptName separator '/') as dName, t. id, t. deptName from (select substring_index (. deptId, ',', B. help_topic_id + 1), ',',-
and control columns are cyclically displayed in the same field, the principle is to read the first loop by using Limit, and then add the number of records read in the first loop to the number of columns displayed in each row. The following code is directly attached:
Code for the first loop:
”/>
Loop code later:
”/>
Of course, there is a more direct method, that is, the first loop of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.